<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<title>reveal.js</title>

		<link rel="stylesheet" href="dist/reset.css">
		<link rel="stylesheet" href="dist/reveal.css">
		<link rel="stylesheet" href="dist/theme/marvin.css">

		<!-- Theme used for syntax highlighted code -->
		<link rel="stylesheet" href="plugin/highlight/monokai.css">

		<style>

      .list > li {
        font-size: 80%;
        margin: 20px;
      }

			.paper {
				box-sizing: border-box;
				border: 0.5px solid gray;
				width:  510.5px;
				height: 600.5px;
				background-size: 30px 30px;
				background-image:
					linear-gradient(to right, grey 0.5px, transparent 0.5px),
					linear-gradient(to bottom, grey 0.5px, transparent 0.5px);
			}

			.curve {
				position: absolute;
				box-sizing: border-box;

				top: 80px;
				width: 410.5px;
				height: 550.5px;
				border-top-right-radius: 410.5px 550.5px;
				border-top:   1px solid crimson;
				border-right: 1px solid crimson;
			}
		</style>
	</head>
	<body>
		<div class="reveal">
			<div class="slides">

				<section>
					<h2>人脸检测与识别</h2>
					<div class="sub-title">Face Detection & Recognition</div>
				</section>

				<section data-auto-animate>
          <div data-id="title">搭建你的实验和开发环境</div>
          <ul class="list">
            <li>哪些是完成任务的必要设备？</li>
            <li>你期望它如何工作？</li>
            <li>如何使其按照你期待的方式工作？</li>
            <li>你通过什么方式告诉它你想让它做的事？</li>
            <li>你通过什么方法观察各种结果/现象？</li>
          </ul>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre><code data-trim data-noescape>
          #!/usr/bin/python
          print 1 + 1
          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre><code data-trim data-noescape>
          $ echo "print 1 + 1" | python
          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          import math

          class Vec:
            def __init__(self, x, y):
              self.x = x
              self.y = y
            
            def add(self, vec):
              self.x += vec.x
              self.y += vec.y
          
            def sub(self, vec):
              self.x -= vec.x
              self.y -= vec.y
        
          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          import math

          class Vec:
            def __init__(self, x, y):
              self.x = x
              self.y = y
            
            def add(self, vec):
              return Vec(self.x + vec.x, self.y + vec.y)

            def sub(self, vec):
              return Vec(self.x - vec.x, self.y - vec.y)

            def mag(self):
              return math.hypot(self.x, self.y)

            def inner(self, vec):
              return self.x * vec.x + self.y * vec.y
          
            def outer(self, vec):
              return self.x * vec.y - self.y * vec.x
          
          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          import math

          class Polygon:

            def __init__(self, vecs):
              self.vecs = vecs
          
            def area(self):
              return [head.outer(tail) for head, tail in zip(self.vecs[:-1], self.vecs[1:])]
                    
          </code></pre>
        </section>


        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          import math

          class Polygon:

            def __init__(self, vecs):
              self.vecs = vecs
          
            # Alternatively ...
            def area(self):
              sum = 0
              
              for head, tail in zip(self.vecs[:-1], self.vecs[1:]):
                sum += head.outer(tail)
              
              return sum

          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          def fibonacci(nth): 
            if nth < 0:
              print('nth should be non-negative')
            elif nth == 0:
              return 0
            elif nth == 1 or nth == 2:
              return 1
            else:
              return fibonacci(nth - 1) + fibonacci(nth - 2)
        
          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          def fibonacci(nth):

            if nth < 0:
              return None
          
            results = []
            for i in range(nth):
              if i <= 1:
                results.append(1)
              else:
                results.append(results[i-1] + results[i-2])

          </code></pre>
        </section>

        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          def fibonacci(nth):

            if nth < 0:
              return None
          
            hehehe = 1
            hohoho = 1
            hahaha = 0
          
            for i in range(nth):
              if i > 1:
                hahaha = hehehe
                hehehe = hohoho
                hohoho = hahaha + hehehe
                
            return hohoho

          </code></pre>
        </section>


        <section data-auto-animate>
          <div data-id="title">快速复习Python</div>
          <pre data-id="code-animation"><code data-trim data-noescape>
          #!/usr/bin/python

          def fibonacci(nth):

            if nth < 0:
              return None
          
            hehehe = 1
            hohoho = 1
          
            for i in range(nth):
              if i > 1:
                [hehehe, hohoho] = [hohoho, hehehe + hohoho]
                
            return hohoho

          </code></pre>
        </section>

        <section>
          <div data-id="title">组装设备</div>
          <img src='./assets/jetson-nano.jpg' />
        </section>

        <section>
          <div data-id="title">引导至桌面系统</div>
          <img src='./assets/ubuntu.jpg' />
        </section>

        <section>
          <div data-id="title">实验 1</div>
          <div>基于OpenCV的人脸识别 (Haar Cascade Algorithm)</div>
        </section>

        <section>
          <div data-id="title">实验 1</div>
          <pre data-id="code-animation" class="stretch"><code data-trim data-noescape>
            import cv2
            import numpy as np
            
            HAAR_CASCADE_XML_FILE_FACE = "./haarcascade_frontalface_default.xml"
            
            def faceDetect():
                # Obtain face detection Haar cascade XML files from OpenCV
                face_cascade = cv2.CascadeClassifier(HAAR_CASCADE_XML_FILE_FACE)
            
                # Video Capturing class from OpenCV
                video_capture = cv2.VideoCapture(0)
            
                if video_capture.isOpened():
                    cv2.namedWindow("Face Detection", cv2.WINDOW_AUTOSIZE)
            
                    while True:
                        return_key, image = video_capture.read()
                        if not return_key:
                            break
            
                        grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
                        detected_faces = face_cascade.detectMultiScale(grayscale_image, 1.3, 5)
            
                        # Create rectangle around the face in the image canvas
                        for (x_pos, y_pos, width, height) in detected_faces:
                            head = (x_pos, y_pos)
                            tail = (x_pos + width, y_pos + height)
                            cv2.rectangle(image, head, tail, (0, 0, 0), 2)
            
                        cv2.imshow("Face Detection Window", image)
            
                        key = cv2.waitKey(30) & 0xff
                        # Stop the program on the ESC key
                        if key == 27:
                            break
            
                    video_capture.release()
                    cv2.destroyAllWindows()
                else:
                    print("Cannot open Camera")
            
            if __name__ == "__main__":
                faceDetect()  
          </code></pre>  
        </section>

        <section>
          <pre><code data-trim data-noescape>
            $ git clone https://gitee.com/marvintau/misc
            </code></pre>  
        </section>  

        <section>
          <pre class="stretch"><code data-trim data-noescape>
            # 下载代码
            $ git clone https://hub.fastgit.org/AlexeyAB/darknet.git
            $ git checkout 64efa721ede91cd8ccc18257f98eeba43b73a6af
            
            # 下载权重文件
            $ cd darknet
            $ wget https://hub.fastgit.org/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights
          </code></pre>  
          
        </section>

        <section>
          <pre class="stretch"><code data-trim data-noescape>
            # 修改Makefile
            GPU=1
            CUDNN=1
            CUDNN_HALF=0
            OPENCV=1
            AVX=0
            OPENMP=0
            LIBSO=0
            ZED_CAMERA=0
            ZED_CAMERA_v2_8=0
            
            # set GPU=1 and CUDNN=1 to speedup on GPU
            # set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
            # set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)
            # set ZED_CAMERA=1 to enable ZED SDK 3.0 and above
            # set ZED_CAMERA_v2_8=1 to enable ZED SDK 2.X            
          </code></pre>  
          
        </section>
        
        <section>
          <pre><code data-trim data-noescape>
            # 向.bash添加nvcc路径（这一步不需要重复操作）
            export PATH=/usr/local/cuda/bin:$PATH
            export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
            export CUDA_ROOT=/usr/local/cuda
          </code></pre>  
        </section>   


        <section>
          <pre><code data-trim data-noescape>
            $ make -j4
          </code></pre>  
        </section>  


        <section>
          <pre class="stretch"><code data-trim data-noescape>
            $ cd darknet
            $ ./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights /dev/video0
            </code></pre>  
        </section>  
      </div>
		</div>

    <script src="dist/reveal.js"></script>
		<script src="plugin/notes/notes.js"></script>
		<script src="plugin/markdown/markdown.js"></script>
		<script src="plugin/highlight/highlight.js"></script>

    <script>
      Reveal.initialize({
				hash: true,

				// Learn about plugins: https://revealjs.com/plugins/
				plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
			})
    </script>

  </body>
</html>